package com.ruoyi.camp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.camp.domain.CFacility;
import com.ruoyi.camp.service.ICFacilityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务设施功能Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/camp/cfacility")
public class CFacilityController extends BaseController
{
    @Autowired
    private ICFacilityService cFacilityService;

    /**
     * 查询服务设施功能列表
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:list')")
    @GetMapping("/list")
    public TableDataInfo list(CFacility cFacility)
    {
        startPage();
        List<CFacility> list = cFacilityService.selectCFacilityList(cFacility);
        return getDataTable(list);
    }

    /**
     * 导出服务设施功能列表
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:export')")
    @Log(title = "服务设施功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CFacility cFacility)
    {
        List<CFacility> list = cFacilityService.selectCFacilityList(cFacility);
        ExcelUtil<CFacility> util = new ExcelUtil<CFacility>(CFacility.class);
        util.exportExcel(response, list, "服务设施功能数据");
    }

    /**
     * 获取服务设施功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:query')")
    @GetMapping(value = "/{facilityId}")
    public AjaxResult getInfo(@PathVariable("facilityId") String facilityId)
    {
        return success(cFacilityService.selectCFacilityByFacilityId(facilityId));
    }

    /**
     * 新增服务设施功能
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:add')")
    @Log(title = "服务设施功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CFacility cFacility)
    {
        return toAjax(cFacilityService.insertCFacility(cFacility));
    }

    /**
     * 修改服务设施功能
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:edit')")
    @Log(title = "服务设施功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CFacility cFacility)
    {
        return toAjax(cFacilityService.updateCFacility(cFacility));
    }

    /**
     * 删除服务设施功能
     */
    @PreAuthorize("@ss.hasPermi('camp:cfacility:remove')")
    @Log(title = "服务设施功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{facilityIds}")
    public AjaxResult remove(@PathVariable String[] facilityIds)
    {
        return toAjax(cFacilityService.deleteCFacilityByFacilityIds(facilityIds));
    }
}
